package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import bean.User;
import service.DeliveryInfoService;

@WebServlet("/DeliveryInfoServlet")
public class DeliveryInfoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public DeliveryInfoServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		DeliveryInfoService service = new DeliveryInfoService();
		
		String page = request.getParameter("page");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		String deliveryno = request.getParameter("deliveryno");
		String transportStatus = request.getParameter("transportStatus");
		String applyStatus = request.getParameter("applyStatus");
		String lackStatus = request.getParameter("lackStatus");
		String addressee = request.getParameter("addressee");
		String payno = request.getParameter("payno");
		Integer userid = null;
		if (request.getSession().getAttribute("user") != null)
			userid = ((User) request.getSession().getAttribute("user")).getId();
		
		String jsonReturn = service.getAllDeliveryJson(userid, page, startTime, endTime, deliveryno, transportStatus, applyStatus, lackStatus, addressee, payno);
		response.getWriter().write(jsonReturn);
	}
}
